package org.squarecap.apps.eventcompanion.web;

import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService;
import org.squarecap.apps.eventcompanion.domain.Congreso;
import org.squarecap.apps.eventcompanion.domain.Participante;

/**
 * A central place to register application converters and formatters. 
 */
@RooConversionService
public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean {

	@Override
	protected void installFormatters(FormatterRegistry registry) {
		super.installFormatters(registry);
		// Register application converters and formatters
	}
	
    public Converter<Participante, String> getParticipanteToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<org.squarecap.apps.eventcompanion.domain.Participante, java.lang.String>() {
            public String convert(Participante participante) {
                return new StringBuilder().append(participante.getNombre()).append(' ').append(participante.getApellido()).append(" - ").append(participante.getEmail()).toString();
            }
        };
    }
	    public Converter<Congreso, String> getCongresoToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<org.squarecap.apps.eventcompanion.domain.Congreso, java.lang.String>() {
            public String convert(Congreso congreso) {
                return new StringBuilder().append(congreso.getTitulo()).toString();
            }
        };
	}
}	   
